// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import store from './store/store'
import BaiduMap from 'vue-baidu-map'

Vue.use(BaiduMap, {
  /* Visit http://lbsyun.baidu.com/apiconsole/key for details about app key. */
  ak: 'hlTOCwmv7dccdMhFXZLMYr1051QD2Vqs'
})
// 提示 and  图片
import {Toast, Image} from 'vant';

Vue.use(Toast);
Vue.use(Image);

import {Lazyload} from 'vant';

Vue.use(Lazyload, {
  // preLoad: 1.3,
  error: 'http://hbimg.b0.upaiyun.com/1e3ead27ad747c7c92e659ac5774587a680bb8d25252-mRVFlu_fw658',
  loading: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1566281534111&di=d044965670c58dfcc47931a16030cf3d&imgtype=0&src=http%3A%2F%2Fimg.zcool.cn%2Fcommunity%2F01412b5a113d83a80121985c87590c.gif'
})

import VueJsonp from 'vue-jsonp'

Vue.use(VueJsonp)

// rem
import setHtmlFontSize from './assets/js/font-size'
import axios from 'axios'
// 将axios挂载到全局
// Vue.prototype.$axios = axios
// 引入封装后的axios方法
Vue.prototype.$post = axios.post
Vue.prototype.$get = axios.get

import api from './api/api.js'

Vue.config.productionTip = false

if (process.env.NODE_ENV === 'development') {
  axios.interceptors.request.use(
    config => {
      config.headers.token = "4bc6d88f-e04d-465b-8dd1-be48af1e50aa";
      return config;
    }
  );
}

// http request 拦截器
axios.interceptors.response.use(
  response => {
    switch (response.data.code) {
      case 0:
        console.log(response.data.msg);
    }
    return response;
  },
  error => {
    if (error.response) {
      switch (error.response.data.code) {
        case 401:
          window.location.href = api.connect + '?url=' + encodeURIComponent(window.location.href);
          break;
        default:
          console.log('系统开小差了,请稍后再试');
          break;
      }
    }
    return Promise.reject(error.response.data) // 返回接口返回的错误信息
  }
);
/* eslint-disable no-new */
new Vue({
  render: h => h(App),
  router,
  store
}).$mount('#app')
